import axios from "axios";

const api = axios.create({
    baseURL : '/api/user',
    timeout : 5000,
    headers: {
    'Content-Type': 'application/json'
    },    
})

export interface CheckAccountResponse{
    code:number,
    message:string,
    data?:any
}

export const CheckAccountExists = async(account:string):Promise<CheckAccountResponse> => {
    const response = await api.get<CheckAccountResponse>('/check-account-exist',
        {
            params:{
                account
            }
        }
    );
    return response.data
}
export const RegisterAccount = async(user:{
    account:string,
    password:string
}):Promise<CheckAccountResponse>=>{
   const response = await api.post<CheckAccountResponse>('./register',user)
   return response.data 
}
export default {CheckAccountExists,RegisterAccount}
